<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var name = "张三";
			var p = new String("李四");

			var str = "ljdfljkdfahlsfhoigflkdfndf,;nfjkldf';df"; //统计f出现的次数
			// var index = str.indexOf('a');
			// console.log(index);

			var sub = str.substring(6, 9);
			// console.log(sub);

			var b = str.startsWith('l');
			b = str.endsWith('df');
			// console.log(b);

			var count = 0;
			var index = -2;
			while ((index = str.indexOf('f')) != -1) {
				count++;
				str = str.substring(index + 1);
			}

			console.log(count);
			/* if (index != -1) {
				count++;
				var sub = str.substring(index + 1);
				index = sub.indexOf('a');
				if (index != -1) {
					count++;
					sub = str.substring(index + 1);
				}			
			} */
		</script>
	</body>
</html>
